home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / ADDRCONF.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  159 lines

  1. #ifndef _ADDRCONF_H
  2. #define _ADDRCONF_H
  3.  
  4. #define RETRANS_TIMER    HZ
  5.  
  6. #define MAX_RTR_SOLICITATIONS        3
  7. #define RTR_SOLICITATION_INTERVAL    (4*HZ)
  8.  
  9. #define ADDR_CHECK_FREQUENCY        (120*HZ)
  10.  
  11. struct prefix_info {
  12.     __u8            type;
  13.     __u8            length;
  14.     __u8            prefix_len;
  15.  
  16. #if defined(__BIG_ENDIAN_BITFIELD)
  17.     __u8            onlink : 1,
  18.                  autoconf : 1,
  19.                 reserved : 6;
  20. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  21.     __u8            reserved : 6,
  22.                 autoconf : 1,
  23.                 onlink : 1;
  24. #else
  25. #error "Please fix <asm/byteorder.h>"
  26. #endif
  27.     __u32            valid;
  28.     __u32            prefered;
  29.     __u32            reserved2;
  30.  
  31.     struct in6_addr        prefix;
  32. };
  33.  
  34.  
  35. #ifdef __KERNEL__
  36.  
  37. #include <linux/in6.h>
  38. #include <linux/netdevice.h>
  39. #include <net/if_inet6.h>
  40.  
  41. #define IN6_ADDR_HSIZE        16
  42.  
  43. extern void            addrconf_init(void);
  44. extern void            addrconf_cleanup(void);
  45.  
  46. extern int                addrconf_notify(struct notifier_block *this, 
  47.                         unsigned long event, 
  48.                         void * data);
  49.  
  50. extern int            addrconf_add_ifaddr(void *arg);
  51. extern int            addrconf_del_ifaddr(void *arg);
  52. extern int            addrconf_set_dstaddr(void *arg);
  53.  
  54. extern struct inet6_ifaddr *    ipv6_chk_addr(struct in6_addr *addr,
  55.                           struct device *dev, int nd);
  56. extern int            ipv6_get_saddr(struct dst_entry *dst, 
  57.                            struct in6_addr *daddr,
  58.                            struct in6_addr *saddr);
  59. extern struct inet6_ifaddr *    ipv6_get_lladdr(struct device *dev);
  60.  
  61. /*
  62.  *    multicast prototypes (mcast.c)
  63.  */
  64. extern int            ipv6_sock_mc_join(struct sock *sk, 
  65.                           int ifindex, 
  66.                           struct in6_addr *addr);
  67. extern int            ipv6_sock_mc_drop(struct sock *sk,
  68.                           int ifindex, 
  69.                           struct in6_addr *addr);
  70. extern void            ipv6_sock_mc_close(struct sock *sk);
  71.  
  72. extern int            ipv6_dev_mc_inc(struct device *dev,
  73.                         struct in6_addr *addr);
  74. extern int            ipv6_dev_mc_dec(struct device *dev,
  75.                         struct in6_addr *addr);
  76. extern void            ipv6_mc_up(struct inet6_dev *idev);
  77. extern void            ipv6_mc_down(struct inet6_dev *idev);
  78. extern void            ipv6_mc_destroy_dev(struct inet6_dev *idev);
  79. extern void            addrconf_dad_failure(struct inet6_ifaddr *ifp);
  80.  
  81. extern int            ipv6_chk_mcast_addr(struct device *dev,
  82.                             struct in6_addr *addr);
  83.  
  84. extern void            addrconf_prefix_rcv(struct device *dev,
  85.                             u8 *opt, int len);
  86.  
  87. extern struct inet6_dev *    ipv6_get_idev(struct device *dev);
  88.  
  89. extern void            addrconf_forwarding_on(void);
  90. /*
  91.  *    Hash function taken from net_alias.c
  92.  */
  93.  
  94. static __inline__ u8 ipv6_addr_hash(struct in6_addr *addr)
  95. {    
  96.     __u32 word;
  97.     unsigned tmp;
  98.  
  99.     /* 
  100.      * We perform the hash function over the last 64 bits of the address
  101.      * This will include the IEEE address token on links that support it.
  102.      */
  103.  
  104.     word = addr->s6_addr[2] ^ addr->s6_addr32[3];
  105.     tmp  = word ^ (word>>16);
  106.     tmp ^= (tmp >> 8);
  107.  
  108.     return ((tmp ^ (tmp >> 4)) & 0x0f);
  109. }
  110.  
  111. static __inline__ int ipv6_devindex_hash(int ifindex)
  112. {
  113.     return ifindex & (IN6_ADDR_HSIZE - 1);
  114. }
  115.  
  116. /*
  117.  *    compute link-local solicited-node multicast address
  118.  */
  119.  
  120. extern __inline__ void addrconf_addr_solict_mult_old(struct in6_addr *addr,
  121.                              struct in6_addr *solicited)
  122. {
  123.     ipv6_addr_set(solicited,
  124.               __constant_htonl(0xFF020000), 0,
  125.               __constant_htonl(0x1), addr->s6_addr32[3]);
  126. }
  127.  
  128. extern __inline__ void addrconf_addr_solict_mult_new(struct in6_addr *addr,
  129.                              struct in6_addr *solicited)
  130. {
  131.     ipv6_addr_set(solicited,
  132.               __constant_htonl(0xFF020000), 0,
  133.               __constant_htonl(0x1),
  134.               __constant_htonl(0xFF000000) | addr->s6_addr32[3]);
  135. }
  136.  
  137.  
  138. extern __inline__ void ipv6_addr_all_nodes(struct in6_addr *addr)
  139. {
  140.     ipv6_addr_set(addr,
  141.               __constant_htonl(0xFF020000), 0, 0,
  142.               __constant_htonl(0x1));
  143. }
  144.  
  145. extern __inline__ void ipv6_addr_all_routers(struct in6_addr *addr)
  146. {
  147.     ipv6_addr_set(addr,
  148.               __constant_htonl(0xFF020000), 0, 0,
  149.               __constant_htonl(0x2));
  150. }
  151.  
  152. extern __inline__ int ipv6_addr_is_multicast(struct in6_addr *addr)
  153. {
  154.     return (addr->s6_addr32[0] & __constant_htonl(0xFF000000)) == __constant_htonl(0xFF000000);
  155. }
  156.  
  157. #endif
  158. #endif
  159.